package com.dhcc.bpm.common.utils.http;

import java.util.HashMap;
import java.util.Map;

public enum Status {
    COMMUNICATE_ERROR("T300", "通讯异常"),
    COMMUNICATE_TIMEOUT_ERROR("T301", "通讯超时"),
    COMMUNICATE_FTP_CONNECT_ERROR("T302", "FTP连接错误"),
    COMMUNICATE_FTP_AUTHENTICATE_ERROR("T303", "FTP登录用户或密码错误"),
    COMMUNICATE_FTP_DECODE_PASSWORD_ERROR("T304", "FTP登录密码解密失败"),
    COMMUNICATE_SERVICE_TIMEOUT_ERROR("T305", "服务内部超时"),
    COMMUNICATE_THIRD_PARTY_TIMEOUT_ERROR("T306", "请求三方超时"),
    COMMUNICATE_CONNECT_REFUSED_ERROR("T307", "建立连接失败，请检查网络或服务是否启动"),
    COMMUNICATE_CONNECT_TIMEOUT_ERROR("T308", "建立连接超时，请检查网络或服务是否启动");


    private String code;
    private String msg;

    private Status(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public static String getMsgByCode(String code) {
        return enumManager.map.get(code);
    }

    private static class enumManager {
        private static final Map<String, String> map = new HashMap<String, String>();

        static {
            Status[] values = Status.values();
            for (Status status : values) {
                map.put(status.getCode(), status.getMsg());
            }
        }
    }
}
